/**
 *  @file application.cpp
 *
 *  @date 19-nov-2009
 *  @author Ives van der Flaas
 */

#include <cassert>
#include <iostream>
#include "application.h"

si::Application::Application(Window *win):
	fWindow(win),
	fCurrentAppSection(0),
	fSplashSection(0),
	fMenuSection(0),
	fGameSection(0),
	fLostSection(0),
	fHighScoresSection(0),
	fGameEnded(false),
	fLastScore(0)
{

}

void si::Application::changeSectionTo(Section sec)
{
	switch(sec)
	{
	case MENU:
		fCurrentAppSection = fMenuSection;
		break;
	case INTRO:
		fCurrentAppSection = fIntroSection;
		break;
	case SPLASH:
		fCurrentAppSection = fSplashSection;
		break;
	case GAME:
		fCurrentAppSection = fGameSection;
		break;
	case LOST:
		fCurrentAppSection = fLostSection;
		break;
	case HIGHSCORES:
		fCurrentAppSection = fHighScoresSection;
		break;
	default:
		assert(false);
		break;
	}

	fCurrentAppSection->youreStarting();

}

bool si::Application::didTheGameEnd()
{
	if(fGameEnded)
	{
		fGameEnded = false;
		return true;
	}
	else
		return false;
}

void si::Application::gameEnded(int score)
{
	fGameEnded = true;
	fLastScore = score;
}
